/*
 * Copyright (c) 2017,安徽皖通科技股份有限公司 All rights reserved.
 */

package com.wttech.dzzf.process.run;

import com.wttech.dzzf.process.service.errordata.ErrorUserNameCollectService;
import com.wttech.dzzf.process.service.CommonConsumerService;
import com.wttech.dzzf.process.service.errordata.HcbPhonesImportService;
import com.wttech.dzzf.process.service.transaction.*;
import com.wttech.dzzf.process.service.transfer.DataTransferService;
import com.wttech.dzzf.process.service.upload.RechargeInfosUploadService;
import com.wttech.dzzf.process.service.upload.ReimburseInfosUploadService;
import com.wttech.dzzf.process.service.upload.ReversalInfosUploadService;
import com.wttech.dzzf.process.service.upload.UploadRequestInfos;
import com.wttech.dzzf.process.service.user.FillAccountInfosService;
import com.wttech.dzzf.process.service.user.RepeatUserInfosCreatorSerivice;
import com.wttech.dzzf.process.service.user.UserInfosCreatorService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Scanner;

/**
 * 程序运行入口
 *
 * @author MaShibo
 */
public class ProcessRunService {

    private static final Logger LOGGER = LoggerFactory.getLogger(ProcessRunService.class);

    public static void main(String[] args) {
        LOGGER.info("请选择要进行的操作：");
        LOGGER.info("1. 填充资金账户信息");
        LOGGER.info("2. 填充货车帮手机号");
        LOGGER.info("3. 创建非重复用户信息");
        LOGGER.info("4. 创建重复用户信息");
        LOGGER.info("5. 生成自测文件");
        LOGGER.info("6. 接口上传数据");
        LOGGER.info("7. 分析建行待迁移数据");
        LOGGER.info("8. 分析错误用户名称数据");
        LOGGER.info("9. 生成冲正数据");
        LOGGER.info("10. 生成充值数据");
        LOGGER.info("11. 生成退款数据");
        LOGGER.info("12. 上传充值相关数据");
        LOGGER.info("13. 上传冲正相关数据");
        LOGGER.info("15. 上传退款相关数据");

        Scanner sc = new Scanner(System.in);
        String select = sc.next();
        int selectVal;
        try {
            selectVal = Integer.parseInt(select);
        } catch (NumberFormatException e) {
            LOGGER.error("非法输入");
            return;
        }
        switch (selectVal) {
            case 1:
                FillAccountInfosService.main(new String[]{});
                break;
            case 2:
                HcbPhonesImportService.main(new String[]{});
                break;
            case 3:
                UserInfosCreatorService.main(new String[]{});
                break;
            case 4:
                RepeatUserInfosCreatorSerivice.main(new String[]{});
                break;
            case 5:
                LOGGER.info("请输入要生成json文件的标识：");
                String nextValue = sc.next();
                CommonConsumerService.main(StringUtils.split(nextValue, ", "));
                break;
            case 6:
                LOGGER.info("请输入要上传的数据项目，并用逗号分隔：");
                String itemsVal = sc.next();
                String[] items = StringUtils.split(itemsVal, ",");
                UploadRequestInfos.main(items);
                break;
            case 7:
                DataTransferService.main(new String[]{});
                break;
            case 8:
                LOGGER.info("已选择，8-分析错误用户名称数据");
                ErrorUserNameCollectService.main(new String[]{});
                break;
            case 9:
                ReverSalInfosCreatorService.main(new String[]{});
                break;
            case 10:
                LOGGER.info("请输入要创建充值记录的日期，用逗号隔开，格式为：YYYY-MM-DD：");
                String inValue = sc.next();
                String[] dateStrs = inValue.split(",");
                RechargeInfosCreatorService.main(dateStrs);
                break;
            case 11:
                ReimburseInfosCreatorService.main(new String[]{});
                break;
            case 12:
                RechargeInfosUploadService.main(new String[]{});
                break;
            case 13:
                ReversalInfosUploadService.main(new String[]{});
                break;
            case 15:
                ReimburseInfosUploadService.main(new String[]{});
                break;
            default:
                LOGGER.info("无此操作");
                break;
        }
    }
}
